<?php


#读取内容
//获取响应参数
/*$response = $_REQUEST['response'];
$customerIdentification=$_REQUEST['customerIdentification'];
$log = new log();
$log_name = "./callback.log"; //log文件路径
$log->log_result($log_name, "【response】:\n" . $response . "\n"."【customerIdentification】".$customerIdentification."\n");
//JSON转数组
$response=json_decode($response,true);

$source=$response['encryption'];
$sign=$response['signature'];

//解密验签
vertify($source,$sign) ;

function   vertify($source,$sign)
{
    $secretKey = "KkniHbkPolMYQ3/EODtMgQ==";
    $request = new YopRequest("BM12345678903732", $secretKey);
    $request->setEncrypt(true);
    $request->setSignRet(true);
    $request->setSignAlg("sha1");
    //解密
    //var_dump($request);
    echo "<br><br>";
    echo $source;
    $result= YopClient::decrypt($request, $source);
    //判断是否解析出明文
    echo "解密明文：";
    var_dump($result);
    //验签
    $validSign = YopSignUtils::isValidResult($result, $secretKey, "sha1",$sign);
     echo "<br>"."验验结果：".$validSign;
    return   $validSign ;
}8
*/

require_once(dirname(__FILE__)."/../lib/YopClient.php");
require_once(dirname(__FILE__)."/../lib/YopClient3.php");
require_once(dirname(__FILE__)."/../lib/Util/YopSignUtils.php");
require_once(dirname(__FILE__)."/../conf/conf.php");
function callback($source){
//  global $private_key;
//  global  $public_key;
//    $paymentPlugin = M('Plugin')->where("code='qm' and  type = 'payment' ")->find(); // 找到支付插件的配置
//    $config_value = unserialize($paymentPlugin['config_value']); // 配置反序列化
//
//    $public_key  = trim($config_value['yop_public_key']);//公钥
//
//    $private_key = trim($config_value['private_key']);//私钥

    $public_key  = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6p0XWjscY+gsyqKRhw9MeLsEmhFdBRhT2emOck/F1Omw38ZWhJxh9kDfs5HzFJMrVozgU+SJFDONxs8UB0wMILKRmqfLcfClG9MyCNuJkkfm0HFQv1hRGdOvZPXj3Bckuwa7FrEXBRYUhK7vJ40afumspthmse6bs6mZxNn/mALZ2X07uznOrrc2rk41Y2HftduxZw6T4EmtWuN2x4CZ8gwSyPAW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KySqxctGOmkfjDj35b3UCwoT0AqzZWNndcKm82IISzO90uDBWe7szqBTW8grrWa/GLSoEpZ9miDFJlsMielg/6Fca8LC29TrZu6NFPaA/M3x7yWESLuayDEUasJCWsYs+sLtD/lS4R0WaqoRWpgjhhYkstQ1bUHp1IVcCgYEAwukpdQayqAVpFjOxr9QNy/LTKxyIj/JAXzEPBJ5APIi77nkVjR9XtDP6Lw+TEnz5z8FPHQsD6r9H7pAbqeEPznXzaW/PJqEAdVh5tQPdJC8fO/oYZqjSnI9OAfYjSKUmlRI9mgR+VpSCKef1BRT1Plf05Fs/Xg984hgMuajWrBMCgYEA0oIST+KLzvA7WVrGzFp3Ydlm5URE8RuYIGegnGcRzyMp3h3DiJalzJfr5eqc2Wujt0re+UZHYjnnnDrbV+cX8ksYJ7iOcS1cLQzvwOdVyLUzstcq7nOcVmRz6oCPlw+4u6mOT76FVamRppu3l9RMwdQZpf8zqGKIUnE4opk3mRcCgYEAyQq4Ww8yikMAiBvxb2bG1/9zwHfNpB9yhaA5p5lt5+hZB6ALrenD8w6jkIGBrx1MWkv+yloqlggALXxxSeAiJR/LcQKH3aHT+N8mFoy9bjFzPyGoawubZgDz7iIsYjIcdQFFrttTxu7NzZVNcbhfGwxs3SzRgQ3lXKc4wE6Mfos=';//私钥
    return YopSignUtils::decrypt($source,$private_key,$public_key);
}
//$data = 'FxTqFZai_fEWEjLwAyOX5Wx6euME8QvKcSJjVjhIyjgkT6GuMSkWF6oFSXya-vnkCBueYIEy8lMHXN65AhUi6zi68SSR5xULmZ9jR3FnykvDZEjzrP_sIemG3Rek6SlysEiftrIg-4clWuwotem_Hwl368zWWZiIXbkn7pSV_R13AJLYlkpxY2u14-6r-vkM-wOAVWEGEgM3lSpeO2I39V0VCOwBigTgEZPdHvxANmFsSp7_u7SNUTSuzDDFHgktrHrOanZSegTkbzDjblAyFhqQMA740uozcp5z9RsP18TfHlos6ENkciLcwhrlG4cQ68z150NGHkxXt-RsJbPnFw$PrwjYcECG57KDO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